

local crads = {
    '半藏',
    '罗宾汉',
    '希尔瓦娜斯',
    '雷诺',
    '烬',
    '艾俄洛斯',
    '血源猎人',
}

local mt = ac.skill['鹰眼']
function mt:on_card(hero,player)
    if hero[self.name] then
        return
    end
    hero[self.name] = true
    for _,name in ipairs(crads) do
        player:set_data(name,true)
    end
    local has = {}
    local pools = table.copy(crads)
    local count = 0
    hero:event '单位-击杀'(function(trg,_,killed)
        count = count + 1
        if count >= 200 then
            count = 0
            local name = table.remove(pools,math.random(#pools))
            has[#has + 1] = name
            if #pools == 0 then
                trg:remove()
            end
            player:send_msg(('|cff00ff00天赋进入卡池：|r|cff00ffff%s|r'):format(name))
        end
        self.show_num = count
    end)
    player:event '卡池-添加卡组'(function(_,_,pool)
        for _,name in ipairs(has) do
            pool[#pool+1] = name
        end
    end)
    
    hero:event '天赋-检测合成后'(function(trg)
        local haves = hero:get_data('拥有天赋表') or {}
        for _,name in ipairs(crads) do
            if not haves[name] then
                return
            end
        end
        trg:remove()
        hero:set_data('完成-计数',hero:get_data('完成-计数',0) + 1)
    end)
    local event1 = hero:event '天赋-检测合成'(function(trg)
        local count = hero:get_data('射手-计数',0)
        if count>=8 then
            trg:remove()
            for _,temp in ipairs(get_card_list(hero,'射手')) do
                local pz = temp['品质']
                if pz~='UR' and pz~='UR+' then
                    hide_card(temp)
                end
            end
            hero:notify('英雄-获得天赋',hero,'血腥狙击')
        end
    end)
    event1:execute()
    self:gc(event1)
end


local mt = ac.skill['黑暗箭矢']
mt.temp = '攻击触发'
mt.cool = 10
mt.missile_art = [[Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl]]

function mt:on_run(target)
    local hero = self.owner
    local damage = hero:get(self['属性1']) * self.data2/100 + hero:get(self['属性2']) * self.data3/100
    local max = self.data1
    for u in ac.selector('unit')
        : range(target,800)
        : enemy(hero)
        : loop()
    do
        if max>0 then
            max = max - 1
            hero:bezier_missile(u,{math.random(90,150),500},self.missile_art,1200,function()
                hero:create_damage(u,damage,self)
            end)
        else
            break
        end
    end
end


local mt = ac.skill['完美谢幕']
mt.model1 = [[7e96ce4004356e83b003786ff08c862a.mdx]]
function mt:on_add()
    local hero = self.owner
    local count = 0
    self:gc(hero:event '单位-攻击命中'(function(_,_,target,data)
        count = count + 1
        
        if count >= self.data1 then
            count = 0
            hero:launch_missile(target,self.model1,1200,0,function()
                local damage = hero:get('攻击') * hero:get('暴击伤害')/100 * 0.8
                hero:create_damage(target,damage,self)
            end)
        end
    end))
end




local mt = ac.skill['黄金箭']
mt.temp = '攻击触发'
mt.cool = 15
mt.missile_art = [[9a015d2fcdbfd91265d9cb3fa4531c89.mdl]]

function mt:on_run(hero,target)
    local damage = hero:get('攻击') * self.data1/100 + hero:get('攻击距离') * self.data2
    local r = hero:get_point() / target:get_point()
    local mover = hero:launch_wave(self.missile_art,r,1200,1600,1.5)
    local lock = {}
    sc.loopUnit(0.03,mover,275,function(_,unit)
        if unit:is_enemy(hero) then
            hero:create_damage(unit,damage,self)
        end
    end):set_lock(lock)
end


local mt = ac.skill['狩猎']

function mt:on_add(target)
    local hero = self.owner
    local count = 0
    self:gc(ac.game:event '游戏-新的一天'(function()
        count = count + 1
    end))
    self:gc(hero:event '单位-造成伤害前'(function(_,_,target,data)
        data:mul(math.floor(count/self.data1)*self.data2)
    end))
end


local mt = ac.skill['弹幕狂潮']
mt.cool = 10
mt.model1 = [[5949ec32130b5a6ac5193f851910edf1.mdx]]
function mt:on_add()
    local hero = self.owner
    local count = 0
    self:gc(hero:event '单位-造成伤害'(function(_,_,target,data)
        if data['暴击'] and not self:is_cooling() then
            count = count + 1
            if count >= self.data1 then
                count = 0
                self:cooling()
                local angle = hero:get_point() / target:get_point()
                local damage = hero:get('攻击') * self.data2/100 + hero:get('攻击距离') * self.data3/100
                local num = 6
                ac.timer(200,self.data4,function()
                    local lock = {}
                    for a=1,num do
                        local r = angle + (a-num/2 -0.5)*10
                        local mover = hero:launch_wave(self.model1,r,900,1200,nil,100)
                        sc.loopUnit(0.03,mover,120,function(_,unit)
                            if unit:is_enemy(hero) then
                                hero:create_damage(unit,damage,self)
                            end
                        end):set_lock(lock)
                    end
                end)
            end
        end
    end))
end
